import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/couponList',
    name: 'coupon',
    meta: { title: '优惠券系统' },
    children: [
      {
        path: 'couponList',
        name: 'couponList',
        component: () => import('@/views/coupon/couponlist'),
        meta: { title: '优惠券列表' }
      },
      // {
      //   path: 'addconfig',
      //   name: 'addconfig',
      //   component: () => import('@/views/coupon/addconfig'),
      //   meta: { title: '新增配置' },
      //   hidden: true
      // },
      // {
      //   path: 'showconfig',
      //   name: 'showconfig',
      //   component: () => import('@/views/coupon/showcoupondetail'),
      //   meta: { title: '查看详情' },
      //   hidden: true
      // },
      // {
      //   path: 'editconfig',
      //   name: 'editconfig',
      //   component: () => import('@/views/coupon/editconfig'),
      //   meta: { title: '修改配置' },
      //   hidden: true
      // },
      {
        path: 'opCheck',
        name: 'opCheck',
        component: () => import('@/views/coupon/opcheck'),
        meta: { title: '优惠券运营审核' }
      },
      {
        path: 'financeCheck',
        name: 'financeCheck',
        component: () => import('@/views/coupon/financecheck'),
        meta: { title: '优惠券财务审核' }
      },
      {
        path: 'activityList',
        name: 'activityList',
        component: () => import('@/views/coupon/activitylist'),
        meta: { title: '领券活动列表' }
      },
      {
        path: 'addactivity',
        name: 'addactivity',
        component: () => import('@/views/coupon/addactivity'),
        meta: { title: '领券活动配置' },
        hidden: true
      },
      {
        path: 'configCenter',
        name: 'configCenter',
        component: () => import('@/views/coupon/configcenter'),
        meta: { title: '领券中心配置' }
      },
      {
        path: 'search',
        name: 'search',
        component: () => import('@/views/coupon/search'),
        meta: { title: '发放优惠券查询' }
      },
      {
        path: 'messageCenter',
        name: 'messageCenter',
        component: () => import('@/views/coupon/messagecenter'),
        meta: { title: '优惠券消息中心' }
      },
      {
        path: 'dataStatistics',
        name: 'dataStatistics',
        component: () => import('@/views/coupon/datastatistics'),
        meta: { title: '优惠券数据统计' }
      },
      {
        path: 'settlementReport',
        name: 'settlementReport',
        component: () => import('@/views/coupon/settlementreport'),
        meta: { title: '财务结算报表' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
